﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ThucTapOnsoft.Models;

namespace ThucTapOnsoft.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        
        public ActionResult Home()
        {
            thuctapEntities1 db = new thuctapEntities1();
            string chuoi = "";
            var product = (from p in db.Products orderby p.Id descending select p).Take(12).ToList();
            for (int i = 0; i < product.Count; i++)
            {
                 chuoi +="<div class=box-hot-item>";
                 chuoi +="<img src=\"" +product[i].Image+ "\"/>";
                 chuoi +="<br /><a>" +product[i].Name+ "</a><br />";
                 chuoi +="<p>Giá bán: " +product[i].Price+ " VND</p>";
                 chuoi +="</div>";
            }
            ViewBag.raw = chuoi;
            ViewBag.Message = "Home";
            return View();
        }
    }
}
